//案件数量统计柱状图
getCharts = function () {
    const chartBox = echarts.init(document.getElementById('case'), 'chalk');
    var birthData = [{
        name: '市容环境',
        birth1: 200,
        birth2: 150
    },
        {
            name: '市政公用',
            birth1: 130,
            birth2: 80
        },
        {
            name: '城市规划管理',
            birth1: 200,
            birth2: 150
        }, {
            name: '工商行政管理',
            birth1: 210,
            birth2: 153
        }, {
            name: '房屋管理',
            birth1: 70,
            birth2: 186
        }, {
            name: '城市建筑管理',
            birth1: 65,
            birth2: 128
        }, {
            name: '农业行政管理',
            birth1: 38,
            birth2: 81
        },
        {
            name: '人防管理',
            birth1: 153,
            birth2: 143
        },
        {
            name: '水行政管理',
            birth1: 193,
            birth2: 20
        },
        {
            name: '绿化管理',
            birth1: 200,
            birth2: 150
        },
    ];
    let option = {
        grid: {
            top: '14%',
            left: '5%',
            right: '5%',
            bottom: '5%',
            containLabel: true,
        },
        tooltip: {
            trigger: 'axis',
            backgroundColor: 'rgba(50,50,50,0.7)',
            textStyle: {
                color: '#fff',
            }
        },
        dataset: {
            source: birthData
        },
        legend: {
            show: true,
            icon: 'circle',
            itemWidth: 30,
            top: -5,
            right: 0,
            itemHeight: 14,
            textStyle: {
                fontSize: 12,
                color: '#E7EFFF',
                fontWeight: 400,
            }
        },
        xAxis: {
            type: 'category',
            offset: 10,
            axisLine: {
                show: true,
                lineStyle: {
                    color: '#0067E0',
                },
            },
            splitLine: {
                show: false,
            },
            axisLabel: {
                fontSize: 12,
                color: '#CFDFFF',
                fontWeight: 400,
                interval: 0,
                rotate: 40
            },
            axisTick: {
                show: false,
            },
        },
        yAxis: {
            type: 'value',
            nameTextStyle: {
                fontSize: 12,
                color: '#CFDFFF',
                fontWeight: 400,
            },
            axisLine: {
                show: false,
            },
            splitLine: {
                show: true,
                lineStyle: {
                    color: 'rgba(130, 147, 181, 0.5)',
                    type: 'dashed'
                },
            },
            axisLabel: {
                fontSize: 12,
                color: '#CFDFFF',
                fontWeight: 400,
            },
            axisTick: {
                show: false,
            },
        },
        series: [
            {
                name: '简易案件',
                type: 'bar',
                barWidth: 10,
                //颜色从上到下渐变
                itemStyle: {
                    normal: {
                        color: '#69DFAE'
                    }
                },

            },
            {
                name: '普通案件',
                type: 'bar',
                barWidth: 10,
                barGap: 0.4,
                itemStyle: {
                    normal: {
                        color: '#FFD15C'
                    }
                },
            },

        ],
    };
    chartBox.setOption(option)
    // 根据页面大小自动响应图表大小
    window.addEventListener("resize", function () {
        chartBox.resize();
    });


}

//地图
mapData = function () {
    //定义地图对象
    var map;

    map = new OpenLayers.Map("mapDiv", {
        allOverlays: true,
        numZoomLevels: 19,
        displayProjection: "EPSG:4490",
        controls: [
            new OpenLayers.Control.Navigation(),
            new OpenLayers.Control.ArgParser(),
            new OpenLayers.Control.Attribution()]
    });
    //创建矢量图层
    var graphicLayer = new OpenLayers.Layer.Vector("graphicLayer", {style: OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default'])});
    //影像图层初始化
    var sdimgLayer = new SDRasterLayer();
    //注记图层初始化
    var sdannoLayer = new SDRSAnnoLayer();
    map.addLayer(sdimgLayer);
    map.addLayer(graphicLayer);
    map.addLayer(sdannoLayer);
    map.setCenter(new OpenLayers.LonLat(117.157797, 36.651712), 18);
    arrMap.forEach(v => {
        tuCeng(graphicLayer, v)
    })
//构造环
    var liner = new OpenLayers.Geometry.LinearRing([
        new OpenLayers.Geometry.Point(117.153239, 36.654776),
        new OpenLayers.Geometry.Point(117.153039, 36.654776),
        // new OpenLayers.Geometry.Point(117.156428,36.653645),
        new OpenLayers.Geometry.Point(117.155552, 36.650235),
        new OpenLayers.Geometry.Point(117.156898, 36.650235),
        new OpenLayers.Geometry.Point(117.161552, 36.650200),
        new OpenLayers.Geometry.Point(117.161752, 36.650435),
        new OpenLayers.Geometry.Point(117.155852, 36.650435),
        new OpenLayers.Geometry.Point(117.154752, 36.652407),
        new OpenLayers.Geometry.Point(117.154752, 36.652407),
        // new OpenLayers.Geometry.Point(117.156469,36.651603),

    ]);
    var polygon = new OpenLayers.Geometry.Polygon([liner]);
    var style = {
        strokeColor: "#fff",
        strokeDashstyle: "dash",
        strokeWidth: 4,
        fillColor: "rgba(0,255,255,0)",
        fillOpacity: 0.5
    };
    var feature = new OpenLayers.Feature.Vector(polygon, null, style);
    graphicLayer.addFeatures([feature]);

}

//词云
function initPublicWordCloud(data){
    var myChart = echarts.init(document.getElementById('public-wordcloud'));
    var option={
        series:[
            {
                type: 'wordCloud',
                sizeRange: [14, 30],
                rotationRange: [0, 0],
                rotationStep: 0,
                gridSize: 30,
                drawOutOfBound: false,
                layoutAnimation: true,
                //颜色随机
                textStyle: {
                    fontSize:12,
                    normal: {
                        color: function () {
                            let colors = ['#efc83d','#23D38B','#785FF3','#3C78EE','#2492EB']
                            return colors[parseInt(Math.random() * 5)];
                        }
                    },
                },
                data:data
            }
        ]
    }
    myChart.setOption(option);
}
//柱状折线图
function initLineBar() {
    var chartDom = document.getElementById('barLine');
    var myChart = echarts.init(chartDom);
    let bar3 = [
        {
            name: '一月',
            value: _.random(20, 100),
            value2: _.random(20, 100),
            value3: _.random(20, 100),
            value4: _.random(20, 100),
        },
        {
            name: '二月',
            value: _.random(20, 100),
            value2: _.random(20, 100),
            value3: _.random(20, 100),
        },
        {
            name: '三月',
            value: _.random(20, 100),
            value2: _.random(20, 100),
            value3: _.random(20, 100),
        },
        {
            name: '四月',
            value: _.random(20, 100),
            value2: _.random(20, 100),
            value3: _.random(20, 100),
        },
        {
            name: '五月',
            value: _.random(20, 100),
            value2: _.random(20, 100),
            value3: _.random(20, 100),
        },
        {
            name: '六月',
            value: _.random(20, 100),
            value2: _.random(20, 100),
            value3: _.random(20, 100),
        },
    ];
    var option = {
        dataset: {
            source: bar3,
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'shadow',
            },
        },
        legend: {
            textStyle: { //图例文字的样式
                color: '#fff',
                fontSize: 12
            },
            data: [
                {
                    name: '累计收件量',
                },
                {
                    name: '累计办结量',
                }, {
                    name: '按期办结量',
                },
                {
                    name: '办结率',
                },
                {
                    name: '按期办结率',
                }
            ],
        },
        xAxis: [
            {
                type: 'category',
                axisLabel: {
                    textStyle: {
                        show: true,
                        color: '#fff'
                    }
                }

            }

        ],
        grid: {},
        yAxis: [
            {
                type: 'value',
                alignTicks: true,
                position: 'left',
                axisLine: {
                    show: true,
                },
                axisLabel: {
                    formatter: '{value} ',
                    textStyle: {
                        show: true,
                        color: '#fff'
                    }
                },

            },
            {
                type: 'value',
                alignTicks: true,
                axisLine: {
                    show: true,
                },
                axisLabel: {
                    formatter: '{value} %',
                },
            },
        ],
        series: [
            {
                type: 'bar',
                name: '累计收件量',
                barWidth: 8,
                itemStyle: {
                    // color:'#fff',
                    normal: {
                        color: 'rgba(231, 234, 97, 1)',
                    },
                },
                encode: {
                    x: 'name',
                    y: 'value',
                },
            },
            {
                type: 'bar',
                name: '累计办结量',
                barWidth: 8,
                itemStyle: {
                    normal: {
                        color: 'rgba(0, 148, 255, 1)',
                    },
                },
                encode: {
                    x: 'name',
                    y: 'value2',
                },
            },
            {
                type: 'bar',
                name: '按期办结量',
                barWidth: 8,
                itemStyle: {
                    normal: {
                        color: 'rgba(57, 220, 182, 1)',
                    },
                },
                encode: {
                    x: 'name',
                    y: 'value3',
                },
            },
            {
                type: 'line',
                color: 'rgba(0, 148, 255, 1)',
                smooth: false,
                name: '办结率',
                symbolSize: 1,
                itemStyle: {
                    normal: {
                        color: 'rgb(231,159,9)',
                    },
                },
                data: [10, 33, 22, 30, 19, 15, 18],
            },
            {
                type: 'line',
                smooth: false,
                color: 'rgba(57, 220, 182, 1)',
                name: '按期办结率',
                symbolSize: 1,
                itemStyle: {
                    normal: {
                        lineStyle: {

                            color: 'rgb(155,18,236)',
                        },
                    },
                },
                data: [10, 36, 29, 38, 95, 19, 17],
            },
        ],
    }


    option && myChart.setOption(option);

}
